package com.minelx.datamicroscope.core.query;

import com.minelx.datamicroscope.core.condition.KeyOperandCondition;
import com.minelx.datamicroscope.core.values.CommonField;

import java.util.List;
import java.util.Map;

public class QueryPath {

    private final String resourceName;

    private final List<AliasedKey> collectedFields;

    private final Map<String, CommonField> connection;

    private final List<KeyOperandCondition> conditions;

    private QueryPath(String resourceName,
                      List<AliasedKey> collectedFields,
                      Map<String, CommonField> connection,
                      List<KeyOperandCondition> conditions) {
        this.resourceName = resourceName;
        this.collectedFields = collectedFields;
        this.connection = connection;
        this.conditions = conditions;
    }

    public void append(QueryEmitter container) {
        container.collectInContainer(connection, conditions, resourceName, collectedFields);
    }

    public static QueryPath create(String resourceName,
                                   List<AliasedKey> collectedFields,
                                   Map<String, CommonField> connection,
                                   List<KeyOperandCondition> conditions) {
        return new QueryPath(resourceName, collectedFields, connection, conditions);
    }
}
